package s2_threadApi;
/*
* join 方法:让调用这个方法的线程先执行完【线程插队】
* */
class MyThread extends Thread{
    public void run()
    {
        for (int i = 0; i < 10; i++)
        {
            System.out.println("线程1: " + i);
        }
    }
}
public class JoinTest2 {
    public static void main(String[] args) throws Exception
    {
        MyThread t = new MyThread();
        t.start();
        for (int i = 0; i < 10; i++)
        {
            System.out.println(Thread.currentThread().getName()+"线程输出" + i);
            if (i==6){
                try {
                    t.join();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
